/*
 * 作者: 侯晓宇
 * 时间: 2017-02-04
 * 说明：
 * Copyright (c) 2016-2017 中研沃兮
 */
define(function(require) {

	var c = require('app/utils/CommonUtils');
	var dbu = require('app/utils/DBUtils');
	var r = {};

	r.getLoginedUser = function(){
		return {
			userid: dbu.kvget('userid'),
			username: dbu.kvget('username'),
			userheadimgurl: dbu.kvget('userheadimgurl'),
			usertel: dbu.kvget('usertel'),
			userunionid: dbu.kvget('userunionid'),
			usertype: dbu.kvget('usertype')
		};
	}
	r.getCurrentRoomSessionid = function(){
		return dbu.kvget('sessionid');
	}
	r.saveCurrentRoomSessionid = function(sessionid){
		dbu.kvset('sessionid',sessionid);
	}
	r.saveUserTel = function(tel){
		dbu.kvset('usertel',tel);
	}
	r.saveUser = function(user){
		dbu.kvset('userid',user.uuid);
		dbu.kvset('username',user.name);
		dbu.kvset('userheadimgurl',user.wxHeadimgurl);
		dbu.kvset('usertel',user.tel);
		dbu.kvset('userunionid',user.wxUnionid);
		dbu.kvset('usertype',user.userType);
	}
	r.isLogined = function() {
		var userid = dbu.kvget("userid");
		return !c.isNullStr(userid);
	};
	r.logout = function(){
		dbu.kvset('userid',"");
		dbu.kvset('username',"");
		dbu.kvset('userheadimgurl',"");
		dbu.kvset('usertel',"");
		dbu.kvset('userunionid',"");
		dbu.kvset('usertype',"");
	}


	return r;
});